home *** CD-ROM | disk | FTP | other *** search
/ PCNET 2006 August - Disc 1 / PCNET_CD_2006_08_1.iso / shareware / AutoHotkey104407_Install.exe / Extras / Run this to install syntax and clip library files for TextPad.ahk < prev    next >
Encoding:
Text File  |  2005-06-03  |  7.5 KB  |  154 lines

  1. ; Done by Rajat for AutoHotkey
  2. ;
  3. ; Script Function:
  4. ;    Install syntax highlighting and clip library files.
  5. ;    Add hotkeys to TextPad for Launching Script and Context Sensitive Help
  6.  
  7. ; June 2, 2005:
  8. ; - Uses a different method to find where AutoHotkey is installed.
  9. ; - Avoids using SetWorkingDir so that this script can be started in any directory.
  10. ; - The "Run script" shortcut has be improved to use ErrStdOut on Windows NT/2k/XP or later.
  11. ; - A simple GUI was added to prompt for extra options at the end of the installation.
  12.  
  13.  
  14. ; Get AutoHotkey path from registry.
  15. RegRead, AhkDir, HKLM, SOFTWARE\AutoHotkey, InstallDir
  16. IfNotExist, %AhkDir%\AutoHotkey.exe  ; Try best-guess instead.
  17. {
  18.     AhkDir = %A_ProgramFiles%\AutoHotkey\AutoHotkey.exe
  19.     IfNotExist, %AhkDir%\AutoHotkey.exe
  20.     {
  21.         ; Allow user to select from dialog, when unable to locate AutoHotkey.
  22.         FileSelectFile, AHKExe, 1, %A_ProgramFiles%, Select the AutoHotkey executable., Executable (*.exe)
  23.         IfNotExist, %AHKExe%
  24.         {
  25.             MsgBox, Can't find AutoHotkey folder.`n`nThis script will now exit.
  26.             ExitApp
  27.         }
  28.         SplitPath, AHKExe, , AhkDir
  29.     }
  30. }
  31.  
  32. ; Gets path to TextPad
  33. RegRead, TextPadDir, HKEY_CLASSES_ROOT, TextPad.tws\shell\open\Command,
  34.  
  35. if TextPadDir =
  36.     RegRead, TextPadDir, HKEY_CLASSES_ROOT, Applications\TextPad.exe\shell\edit\Command,
  37.     
  38. if TextPadDir =
  39.     TextPadDir = %A_ProgramFiles%\TextPad 4  ; Try a best-guess location.
  40. else
  41. {
  42.     StringReplace, TextPadDir, TextPadDir, ", , all  ; Remove all double quotes.
  43.     SplitPath, TextPadDir, , TextPadDir
  44. }
  45.  
  46. IfNotExist, %TextPadDir%
  47. {
  48.     MsgBox, TextPad could not be found (the directory "%TextPadDir%" does not exist).`n`nThis script will now exit.
  49.     ExitApp
  50. }
  51.  
  52. Gui -SysMenu
  53. Gui, Font, s12
  54. Gui, Add, Text, , This script will install syntax highlighting and clip library files for TextPad v4.`nSelect any extra options you want enabled:
  55. Gui, Font, s10
  56. Gui, Add, Checkbox, checked vDefaultEditor, Make TextPad the default editor for AutoHotkey scripts.
  57. Gui, Font, cRed
  58. Gui, Add, Text, y+20, Warning:%A_Space%
  59. Gui, Font, cDefault
  60. Gui, Add, Text, x+0, If you have any custom tool items in your TextPad Tools menu,`nchecking any of the following might replace/overwrite them.
  61. Gui, Add, Checkbox, vShortcutRun xm, Make 'Ctrl+1' a shortcut for running the script currently loaded in TextPad.
  62. Gui, Add, Checkbox, vShortcutHelp, Make 'Ctrl+2' a shortcut for AutoHotkey context sensitive help in TextPad.
  63. Gui, Add, Checkbox, vShortcutIntelliSense, Make 'Ctrl+3' a shortcut for starting AutoHotkey IntelliSense in TextPad.
  64. Gui, Add, Text, , Note: The shortcut keys above can be changed in TextPad 'Configure Menu > Preferences > KeyBoard'
  65. Gui, Add, Button, y+20 w100 Default, &Install
  66. Gui, Add, Button, x+20 wp, &Cancel
  67. Gui, Show, , Configure TextPad for AutoHotkey
  68. return
  69.  
  70.  
  71.  
  72. GuiClose:
  73. ButtonCancel:
  74. ExitApp
  75.  
  76.  
  77.  
  78. ButtonInstall:
  79. Gui Submit
  80. ExtrasPath = %AhkDir%\Extras\Editors\TextPad
  81.  
  82. FileCopy, %ExtrasPath%\AutoHotkey.syn, %TextPadDir%\system, 1
  83. if ErrorLevel <> 0
  84. {
  85.     MsgBox, Could not copy %ExtrasPath%\AutoHotkey.syn
  86.     ExitApp
  87. }
  88. FileCopy, %ExtrasPath%\AutoHotkey.tcl, %TextPadDir%\Samples, 1
  89. if ErrorLevel <> 0
  90. {
  91.     MsgBox, Could not copy %ExtrasPath%\AutoHotkey.tcl
  92.     ExitApp
  93. }
  94.  
  95. ; Now write the reg keys (use the non-abbreviated root key names in case user has an older version of AutoHotkey)
  96. RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Document Classes\AutoHotkey, Type, 2
  97. RegWrite, REG_MULTI_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Document Classes\AutoHotkey, Members, *.ahk
  98. RegWrite, REG_BINARY, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Document Classes\AutoHotkey, Properties, 46000000010000000100000001000000
  99. RegWrite, REG_BINARY, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Document Classes\AutoHotkey, Colors, 010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000008006c800010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000008080800001000000
  100. RegWrite, REG_BINARY, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Document Classes\AutoHotkey, SyntaxProps, 01000000
  101. Regwrite, REG_BINARY, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Document Classes\AutoHotkey,TabStops,00000000000000000400040000000000406CB800C40306004AD85000FFFFFFFF18EE1200C805B80000010000FE32470018EE12008D000000C805B800904E1500E803B80044EE12000000000078DD4F0018EE120001000000E803B800ACF91200BE02050001000000E803B8008D00000001000000ACF9120000000000904E150008EE120004F41200CFE7520000000000
  102. RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Document Classes\AutoHotkey, SyntaxFile, AutoHotkey.syn
  103. RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Document Classes\AutoHotkey, WordChars, _
  104.  
  105. if DefaultEditor = 1
  106.     RegWrite, REG_SZ, HKEY_CLASSES_ROOT, AutoHotkeyScript\Shell\Edit\Command, , "%TextPadDir%\TextPad.exe" "`%1"
  107.  
  108. if ShortcutRun = 1
  109. {
  110.     ; Tried using the following, but it doesn't seem to add much value in TextPad because unlike EditPlus,
  111.     ; it put the caret/focus to the line indicated in the syntax error message.  In other words, the standard
  112.     ; syntax-error dialog is probably more useful since it doesn't open a secondary TextPad window containing
  113.     ; the results of every script launch:
  114.     ; Command: %comspec%
  115.     ; Parameters: /c ""%AhkDir%\AutoHotkey.exe" /ErrorStdOut "$File""
  116.     RegWrite, REG_BINARY, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\0, Properties, 000000005680000044000000
  117.     RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\0, MenuText, Run Script
  118.     RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\0, Command, %AhkDir%\AutoHotkey.exe
  119.     RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\0, Parameters, "$File"
  120.     RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\0, Folder, $FileDir
  121.     RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\0, RE,
  122. }
  123.  
  124.  
  125. if ShortcutHelp = 1
  126. {
  127.     RegWrite, REG_BINARY, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\1, Properties, 020000005780000004000000
  128.     RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\1, MenuText, AutoHotkey Help
  129.     RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\1, Command, HH.EXE
  130.     RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\1, Parameters, %AhkDir%\AutoHotkey.chm
  131.     RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\1, Folder,
  132.     RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\1, RE,
  133. }
  134.  
  135.  
  136. if ShortcutIntelliSense = 1
  137. {
  138.     Regwrite, REG_BINARY, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\2, Properties, 000000005880000044000000
  139.     Regwrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\2, MenuText, IntelliSense for AutoComplete
  140.     Regwrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\2, Command, %AhkDir%\AutoHotkey.exe
  141.     Regwrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\2, Parameters, "%TextPadDir%\system\IntelliSense.ahk"
  142.     Regwrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\2, Folder, $FileDir
  143.     Regwrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\2, RE,
  144.  
  145.     FileCopy, %AhkDir%\Extras\Scripts\IntelliSense.ahk, %TextPadDir%\system, 1
  146.     FileCopy, %AhkDir%\Extras\Editors\Syntax\Commands.txt, %TextPadDir%\system\AHKCommands.txt, 1
  147. }
  148.  
  149. SplashTextOn,,, Installation Complete
  150. Sleep 2000
  151. SplashTextOff
  152.  
  153. ExitApp  ; Must do this since GUI scripts are persistent.
  154.